﻿@model MyMvc.Model.Models.Article
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <title>修改文章</title>
    <link href="~/Content/jquery-easyui-1.3.1/themes/icon.css" rel="stylesheet" />
    <link href="~/Content/jquery-easyui-1.3.1/themes/default/easyui.css" rel="stylesheet" />
    <link href="~/Content/Site.css" rel="stylesheet" />
    <script src="~/Scripts/jquery.unobtrusive-ajax.js"></script>

    <script src="~/Content/jquery-easyui-1.3.1/jquery-1.8.0.min.js"></script>
    <script src="~/Content/jquery-easyui-1.3.1/jquery.easyui.min.js"></script>
    <script src="~/Content/jquery-easyui-1.3.1/locale/easyui-lang-zh_CN.js"></script>
     <script src="~/Scripts/ckeditor/ckeditor.js"></script>
    <script type="text/javascript">
        $(function () {
            ButtonClickEvent();
        });
        //实现修改的操作
        function ButtonClickEvent() {
            $("#btnUpdata").click(function () {
                //验证表单是否通过
                var validate = $('#ff').form('validate');
                //构造传递的参数，
                var da = CKEDITOR.instances.Content1.getData();
                if (validate == false) {
                    return false;
                }
                else {
                    //构造传递的参数，
                    var postData = {
                        ID:$("#ID").val(),
                        Title: $("#Title").val(),
                        Category: $("#Category").val(),
                        Content1: escape(da),
                        Count: $("#Title").val(),
                        Author: $("#Author").val(),
                    };
                }
                //异步传递数据到前台进行添加
                $.post("/AddArticle/UpdataArticleMethod", postData, function (data) {
                    if (data == "OK") {
                       // $.messager.alert("友情提示", "修改成功");
                        location.href = "/Literature/Index";
                    }
                    else {
                        $.messager.alert("友情提示", "修改失败，请您检查");
                    }
                });

            });
        }

        //返回文章列表
        function backArticle() {
            location.href = "/Literature/Index";
        }
    </script>
</head>
<body>
    <div>
    <form id="ff" method="post" novalidate="novalidate">
        <fieldset>
            <legend>正在修改 @Model.ID @Model.Title 文章</legend>
            <p>
                <label for="ID">ID:</label>
                <input class="easyui-validatebox" type="text" id="ID" value="@Model.ID" name="ID" readonly="true"/>
                <label for="Title">标题：</label>
                <input class="easyui-validatebox" type="text" id="Title" value="@Model.Title" name="Title" data-options="required:true,validType:'length[1,32]'" />
                 <label for="Category">所属类别：</label>
                <input class="easyui-validatebox" type="text" id="Category" value="@Model.Category" name="Category" data-options="required:true,validType:'length[1,32]'" readonly="true" />
                 <label for="Author">作者：</label>
                <input class="easyui-validatebox" type="text" id="Author" name="Author" value="@Model.Author" data-options="required:true,validType:'length[1,32]'" />
            </p>

            <p>
                <label for="Content1">内容:</label>
                <textarea cols="150" rows="10" id="Content1"  name="Content1">@Model.Content1</textarea>
                <script type="text/javascript">
                    CKEDITOR.replace('Content1', {
                        skin: 'kama',
                        height: 150,
                        width: 950
                    });
                </script>
            </p>
            <p><a href="#" class="easyui-linkbutton" id="btnUpdata" iconcls="icon-ok">确认更改</a>
                <a href="#" class="easyui-linkbutton" id="btnBack" iconcls="icon-ok">返回文章管理页面</a>
            </p>
        </fieldset>
    </form>
        </div>
</body>
</html>
